package member;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.sql.PreparedStatement;
import java.util.ArrayList;

import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.sql.DataSource;

import common.misc.StringMisc;
import member.MemberTO;

public class MemberDAOOracle {

	 private DataSource  jdbcFactory;
	/* String kind1Table;
	 String kind2Table;
	 String perfumeTable;	
	 String kind1;
	 String kind2;*/

	 
	 public MemberDAOOracle() throws NamingException {
			
			Context context  = new InitialContext();
			jdbcFactory  = ( DataSource ) context.lookup( "java:comp/env/jdbc/Oracle11g" );
			
	 }//end
	 
	 public void memInsert(MemberTO memlist) throws SQLException{
	 	Connection con=null;
		PreparedStatement pstmt = null;
	 	
		try{
			con=jdbcFactory.getConnection();
			//stmt=con.createStatement();
			
			String sql="INSERT INTO member(id,pw,name,zipcode,addr,birth,gender,hp,email,reg_date) VALUES(?,?,?,?,?,?,?,?,?,sysdate)";
			pstmt = con.prepareStatement(sql);
			
			pstmt.setString(1, memlist.getId());
			pstmt.setString(2, memlist.getPw());
			pstmt.setString(3, memlist.getName());
			pstmt.setString(4, memlist.getZipcode());
			pstmt.setString(5, memlist.getAddr());
			pstmt.setString(6, memlist.getBirth());
			pstmt.setString(7, memlist.getGender());
			pstmt.setString(8, memlist.getHp());
			pstmt.setString(9, memlist.getEmail());
			
			pstmt.executeQuery();
			
		}catch(SQLException sqle){
			throw sqle;
		}finally{
			  if(pstmt !=null) pstmt.close();
			  if(con !=null) con.close();
		}//end try~catch
	}//end
}
